package cn.gjxblog.core.event.jdk.demo2;

import org.junit.Test;

import java.util.EventListener;
import java.util.EventObject;

/**
 * 测试JDK1.1中的EventObject 和 EventListener
 */
public class TestEvent {

    @Test
    public void test(){
        MyEventObject myEventObject = new MyEventObject("123");

        MyEventListener myEventListener = new MyEventListener();
        myEventListener.onApplication(myEventObject);

    }

    static class MyEventObject extends EventObject{

        /**
         * Constructs a prototypical Event.
         *
         * @param source The object on which the Event initially occurred.
         * @throws IllegalArgumentException if source is null.
         */
        public MyEventObject(Object source) {
            super(source);
        }
    }

    static class MyEventListener implements EventListener{

        void onApplication(MyEventObject myEventObject){
            System.out.println(myEventObject.getSource());
        }
    }


}
